/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package toesp.util;

/**
 *
 * @author satria
 */
public class pagingUtil {

    private int totalRow = 0;
    private int rowPerPage = 20;
    private int currentPage = 1;
    private int pagingPart = 5;
    private int pageCount = 1; 
    
    public pagingUtil(){        
    }
    
     /**
     * @param pageCount the pageCount to set
     */
    public void setPageCount() {
        this.pageCount = getTotalRow() / getRowPerPage();
        if (totalRow % rowPerPage > 0) {
            this.pageCount++;
        }
    }
    
    public String getPagingStatus(){        
        return "Page "+currentPage + " of " + pageCount ;
    }
     

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public void setPagingPart(int pagingPart) {
        this.pagingPart = pagingPart;
    }

    public void setRowPerPage(int rowPerPage) {
        this.rowPerPage = rowPerPage;
    }

    public void setTotalRow(int totalRow) {
        this.totalRow = totalRow;
    }

    public int[] getRange() {
        int start = (getCurrentPage() - 1) * getRowPerPage();
        int[] i = {start, start + getRowPerPage()};
        return i;
    }

    public int[] getLimit() {
        int[] i = {(getCurrentPage() - 1) * getRowPerPage(), getRowPerPage()};
        return i;
    }
        

    /**
     * @return the totalRow
     */
    public int getTotalRow() {
        return totalRow;
    }

    /**
     * @return the rowPerPage
     */
    public int getRowPerPage() {
        return rowPerPage;
    }

    /**
     * @return the currentPage
     */
    public int getCurrentPage() {
        return currentPage;
    }

    /**
     * @return the pagingPart
     */
    public int getPagingPart() {
        return pagingPart;
    }

    /**
     * @return the pageCount
     */
    public int getPageCount() {
        return pageCount;
    }


    
}
